/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package wumpus.gui;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

/**
 *
 * @author dolalima
 */
public class Square extends javax.swing.JPanel {

    SquareTypeEnum type = SquareTypeEnum.EMPTY;
    boolean user = false;

    /**
     * Creates new form Square
     */
    public Square() {
        initComponents();
        ImageIcon image;
        updateIcon();
    }

    public SquareTypeEnum getType() {
        return type;
    }

    public void setType(SquareTypeEnum type) {
        this.type = type;
        updateIcon();
    }

    public void updateIcon() {
        ImageIcon image = null;
        if (type == SquareTypeEnum.EMPTY) {
            image = null;
        } else if (type == SquareTypeEnum.HOLE) {
            image = new ImageIcon("./icons/hole-icon-24.png");
        }else if(type == SquareTypeEnum.WUMPUS) {
            image = new ImageIcon("./icons/ghost-icon-24.png");
        }else if(type == SquareTypeEnum.CHEST) {
            image = new ImageIcon("./icons/chest-icon-24.png");
        }
        
        if(user){
            image = new  ImageIcon("./icons/person-icon-24.png");
        }        
        
        iconLabel.setIcon(image);
        
    }

    public boolean isUser() {
        return user;
    }

    public void setUser(boolean user) {
        this.user = user;
        updateIcon();
    }

    public JLabel getIconLabel() {
        return iconLabel;
    }

    public void setIconLabel(JLabel iconLabel) {
        this.iconLabel = iconLabel;
    }


/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        iconLabel = new javax.swing.JLabel();

        setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        setMaximumSize(new java.awt.Dimension(16, 16));
        setLayout(new java.awt.GridBagLayout());
        add(iconLabel, new java.awt.GridBagConstraints());
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel iconLabel;
    // End of variables declaration//GEN-END:variables
}
